/**
 * Express配置
 */

var express = require('express')
  , session = require('express-session');

module.exports = function (app, config) {

  app.use(express.compress({
    filter: function (req, res) {
      return /json|text|javascript|css/.test(res.getHeader('Content-Type'))
    },
    level: 9
  }))


  app.use(express.logger('dev'));
  //app.use(express.json());
  //app.use(express.urlencoded());
  app.use(session({ secret: 'keyboard cat', name: 'blogconnect.sid', cookie: { maxAge: 60*60000 }}));
  app.use(express.bodyParser());

  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(config.root + '/public'));

  app.use('/upload', express.static(__dirname + '/upload'));
  // set views path, template engine and default layout
  app.set('views', config.root + '/app/views')
  app.set('view engine', 'jade')

  // development env config
  app.configure('development', function () {
    app.locals.pretty = true
  })
}
